public class Solution2193 {
    public int minMovesToMakePalindrome(String s) {
        int ans=0;
        for (int i=0;i<s.length()/2;i++){
            char c=s.charAt(i);
            for (int j=s.length()-i-1;j>=i;j--){
                if (j==i){
                    ans++;
                    s=s.substring(0,i).concat(s.substring(i+1,i+2).concat(s.substring(i,i+1)).concat(s.substring(i+2)));
                    i--;
                    break;
                }
                if (s.charAt(j)==c){
                    ans+=s.length()-i-1-j;
                    s=s.substring(0,j).concat(s.substring(j+1,s.length()-i)).concat(s.substring(j,j+1)).concat(s.substring(s.length()-i));
                    break;
                }
            }
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(new Solution2193().minMovesToMakePalindrome("aabb"));
    }
}
